
<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ page import="java.sql.*"%>
<%@ page import="javax.sql.DataSource" %>
<%@ page import="javax.naming.*"%>
<html>
<head>   
    <title>测试JBoss/MySQL连接池</title>   
</head> 
<body>
    <%
    out.print("测试JBOSS连接池<br/>");
    try{
    InitialContext initCtx = new InitialContext();
    DataSource ds = (DataSource)initCtx.lookup("MySqlDS");//注意这里，如果你的JNDI名字和我的不一样，那这个“MySqlDS”要改！
    Connection conn = ds.getConnection();
    out.print("MySQL connection pool runs perfectly!");
    conn.close();
    }
    catch(Exception ex){
    out.println("连接错误：");
    out.print(ex.getMessage());
    }
    %>
    
    很好。很好。不错赫尔鹅鹅鹅鹅鹅鹅鹅鹅鹅鹅鹅鹅鹅鹅鹅鹅鹅鹅鹅。
</body>
</html>